package it.maganar.lesscaos.entity;

import it.maganar.lesscaos.util.TipoVeicolo;

import java.io.Serializable;
import java.sql.Date;
import java.sql.Time;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.OrderBy;
import javax.persistence.Table;

@SuppressWarnings("unchecked")
@Entity
@Table(name="Disponibilita")
public class Disponibilita implements Serializable {

	private int id;
	private int numPosti;
	private TipoVeicolo tipoVeicolo;
	private Time orarioPart;
	private Time orarioArr;
	private Date data;
	private Tappa partenza;
	private Tappa arrivo;
	private User issuer;
	private List listaTappe = new ArrayList();
	
	@Id
	@GeneratedValue
	@Column(name="id")
	public int getId(){
		return id;
	}

	public void setId(int id){
		this.id = id;
	}
	
	@Column(name="numPosti")
	public int getNumPosti() {
		return numPosti;
	}
	public void setNumPosti(int numPosti) {
		this.numPosti = numPosti;
	}
	
	//@Column(name="issuer")
	@ManyToOne
	public User getIssuer() {
		return issuer;
	}
	public void setIssuer(User issuer) {
		this.issuer = issuer;
	}
	
	@Column(name="tipoVeicolo")
	public TipoVeicolo getTipoVeicolo() {
		return tipoVeicolo;
	}
	public void setTipoVeicolo(TipoVeicolo tipoVeicolo) {
		this.tipoVeicolo = tipoVeicolo;
	}
	
	@Column(name="orarioPart")
	public Time getOrarioPart() {
		return orarioPart;
	}
	public void setOrarioPart(Time orarioPart) {
		this.orarioPart = orarioPart;
	}
	
	@Column(name="orarioArr")
	public Time getOrarioArr() {
		return orarioArr;
	}
	public void setOrarioArr(Time orarioArr) {
		this.orarioArr = orarioArr;
	}
	
	@Column(name="data")
	public Date getData() {
		return data;
	}
	public void setData(Date data) {
		this.data = data;
	}
	
	@OneToOne
	//@Column(name="partenza")
	public Tappa getPartenza() {
		return partenza;
	}
	public void setPartenza(Tappa partenza) {
		this.partenza = partenza;
	}

	@OneToOne
	//@Column(name="arrivo")
	public Tappa getArrivo() {
		return arrivo;
	}
	public void setArrivo(Tappa arrivo) {
		this.arrivo = arrivo;
	}

	@Column(name="listaTappe")
	@OneToMany(targetEntity=it.maganar.lesscaos.entity.Tappa.class, fetch=FetchType.EAGER)
	@OrderBy("id")
	//@JoinColumn(name="id")
	public List getListaTappe() {
		return listaTappe;
	}
	public void setListaTappe(List listaTappe) {
		this.listaTappe = listaTappe;
	}
	
	
	
	
	
	
	
	
	
}
